<?php
class node {
    public $value;
    public $nextNode;

    public function __construct ($value) {
        $this->value = $value;
    }
}

class nodeList {
    public $header;
    public $current;
    public $length;

    public function __construct($headValue) {
        $this->header = new node($headValue);
        $this->current = $this->header;
        $this->length = 1;
        echo "create nodeList suc, header value is " . $this->header->value;
        echo "\n";
    }

    public function addNode($nodeValue) {
        $this->current->nextNode = new node($nodeValue);
        $this->current = $this->current->nextNode;
        $this->length += 1;
        echo "add node suc, current node value: " . $this->current->value . "\n";
        echo "current length is " . $this->length . "\n";
    }

    public function getLength() {
        return $this->length;
    }
}
$nodeList = new nodeList(1);
$nodeList->addNode(2);
